package com.smmisia.article.controller;

import com.smmisia.article.request.FriendAddRequest;
import com.smmisia.article.response.socket.FriendResponse;
import com.smmisia.article.service.FriendService;
import com.smmisia.common.Result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/friend")
@Tag(name = "好友")
public class FriendController {

    @Autowired
    private FriendService friendService;

    /**
     * 添加好友
     * @param request
     * @return
     */
    @PostMapping("/add")
    @Operation(summary = "添加好友")
    public Result<String> add(@Valid @RequestBody FriendAddRequest request){
        return friendService.add(request);
    }

    /**
     * 同意/拒绝/拉黑好友
     * @param id
     * @param status
     * @return
     */
    @GetMapping("/accept")
    @Operation(summary = "同意/拒绝/拉黑好友")
    public Result<String> accept(@RequestParam Integer id,@RequestParam Integer status){
        return friendService.accept(id,status);
    }

    /**
     * 获取在线好友
     * @return
     */
    @GetMapping("online")
    @Operation(summary = "获取在线好友")
    public Result<List<String>> online(){
        return friendService.online();
    }
}
